// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

#pragma once

#include "gl\GL.h"    // Include the standard OpenGL headers
#include "gl\GLU.h"   // Add the utility library

#include "UberViewerDoc.h"

class COpenGLView : public CView
{
// Construction
protected: // create from serialization only
	COpenGLView();
	DECLARE_DYNCREATE(COpenGLView);

	HGLRC    m_hRC;
	HDC      m_hDC;
	CDC     *m_pDC;

// Attributes
private:
	CPoint org;

	double m_AspectRatio;
	double m_WindowWidth, m_WindowHeight;

    float   m_zoom;
    float   m_xpan, m_zpan;
    float   m_xrot, m_zrot;

//	std::map <CString, unsigned int> textures;
	unsigned int mapTexture;

private:
	virtual void RenderScene() {};

// Implementation
public:
	int		SetupLights();
	int		SetupMatrices();

// Overrides
public:
//	virtual void OnInitialUpdate();
	void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

	unsigned int AddTexture(int width, int height, int format, BYTE *buffer);

// Generated message map functions
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

	virtual void OnKillFocus(CWnd *pNewWnd);

	void ReplaceTexture(unsigned int id, int width, int height, int format, BYTE *data);
    void DeleteTexture(unsigned int id);

protected:
	afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct); 
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnDestroy();

    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta ,CPoint pt);

    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);

	afx_msg void OnContextMenu(CWnd*, CPoint point);
	afx_msg void OnFilePrintPreview();


// Implementation
public:
	virtual ~COpenGLView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	DECLARE_MESSAGE_MAP()
};

